package com.cxs.controller;

import com.cxs.enums.HospitalErrorResultEnum;
import com.cxs.exception.HospitalException;
import com.cxs.service.DocterService;
import com.cxs.service.RegisterService;
import com.cxs.service.ReportService;
import com.cxs.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

/*
 * @Author:cxs
 * @Date:2021/10/19  15:41
 * @Version 1.0
 * @Motto:放下杂念,只为迎接明天更好的自己
 * */
@Slf4j
@RestController
@RequestMapping("/main")
public class HomeController {
    @Autowired
    public DocterService docterService;

    @Autowired
    private ReportService reportService;

    @Autowired
    private RegisterService registerService;

    /**
     * 排班请求
     * @param day
     * @return
     */
    @PostMapping("/paiban/{day}")
    public Result paibanList(@PathVariable("day") String day){
        if (StringUtils.isEmpty(day)) {
            log.info("【排班信息】:排版天数不能为空,day = {}",day);
            throw new HospitalException(HospitalErrorResultEnum.DOCTER_SHEDULE_ERROR.getCode(),"【排班信息】:排版天数不能为空");
        }

        return Result.Ok(docterService.sheduleList(day));
    }

    /**
     * 门诊总人数
     * @return
     */
    @GetMapping("/Total")
    public Long recordTotal(){
        return reportService.reportCount();
    }

    /**
     * 今日门诊人数
     * @return
     */
    @GetMapping("/currentNum")
    public Long currentNum(){
        return reportService.todayCount();
    }

    /**
     * 住院总人数
     * @return
     */
    @GetMapping("/zhuyuanTotal")
    public Long zhuyuanTotal(){
        return registerService.zhuyuanTotal();
    }

    /**
     * 今日住院人数
     * @return
     */
    @GetMapping("/currentZhuYuan")
    public Long currentZhuYuan(){
        return registerService.todayTotal();
    }
}
